package yunwo.cn.yzstation.view.activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.util.Log;

import com.baidu.android.pushservice.PushConstants;
import com.baidu.android.pushservice.PushManager;

import me.leolin.shortcutbadger.ShortcutBadger;
import yunwo.cn.yzstation.R;
import yunwo.cn.yzstation.base.MyBaseActivity;
import yunwo.cn.yzstation.utils.BadgeUtils;

/**
 * Created by lao on 2017/9/8.
 */

public class WelcomeActivity extends MyBaseActivity {

    private SharedPreferences mInformation;
    private SharedPreferences.Editor mInformationedit;
    private Intent mIntent;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mInformation = getSharedPreferences("information", Context.MODE_PRIVATE);
        mInformationedit = mInformation.edit();
        initEvent();
        PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, "N8vEcY5RXRw70xME6LdSr4B1");
      /*  BadgeUtils.setBadgeCount(WelcomeActivity.this,0);    公司N8vEcY5RXRw70xME6LdSr4B1   个人X8C6FUudeIhqZnMokaGt8TqG
        ShortcutBadger.applyCount(WelcomeActivity.this, 0);*/
    }

    private void initEvent() {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                jump();
            }
        }, 2000);
    }

    private void jump() {
        String token = "";
        if (!mInformation.getString("token", "").equals("")) {
            mIntent = new Intent(WelcomeActivity.this, MainActivity.class);
            startActivity(mIntent);
            finish();
        }else {
            mIntent = new Intent(WelcomeActivity.this, LoginActivity.class);
            startActivity(mIntent);
            finish();
        }

    }

    @Override
    protected String settiltile() {
        return null;
    }

    @Override
    protected int getLayoutRsid() {
        return R.layout.activity_welcome;
    }
}
